package cn.signalpha.modules.shop.service;

import cn.signalpha.modules.shop.entity.OrderRefundLog;
import cn.signalpha.modules.shop.mapper.OrderRefundLogMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

import static cn.signalpha.common.cache.CacheNames.EXPIRATION_TIME_7;
import static cn.signalpha.common.cache.CacheNames.ORDER_REFUND_LOG;

/**
 * 服务类
 *
 * @author signalpha
 */
@Service
public class OrderRefundLogService extends ServiceImpl<OrderRefundLogMapper, OrderRefundLog> {

	@Cacheable(cacheNames = ORDER_REFUND_LOG + EXPIRATION_TIME_7, key = "#refundId")
	public List<OrderRefundLog> listByRefundId(Long refundId) {
		return baseMapper.selectList(Wrappers.<OrderRefundLog>lambdaQuery().eq(OrderRefundLog::getRefundId, refundId).orderByDesc(OrderRefundLog::getId));
	}
	@CacheEvict(cacheNames = ORDER_REFUND_LOG, key = "#refundId")
	public void removeCacheByRefundId(Long refundId) {
	}

}

